#pragma once


#include <hash_map>
#include "CG_flip_flop.h"


using namespace std;
using stdext::hash_map;


static const size_t InitialFNV = 2166136261U;
static const size_t FNVMultiple = 16777619;


class hasher
{
	public:
		const static size_t bucket_size = 10;       
		const static size_t min_buckets =(1 << 10);
		
		hasher()
		{
		}

		size_t operator()(const string& s) const
		{
			size_t len = (size_t)s.length();
			size_t hash = InitialFNV;
			for(size_t i = 0; i < len; i++)
			{
				hash = hash ^ (s[i]);       /* xor  the low 8 bits */
				hash = hash * FNVMultiple;  /* multiply by the magic number */
			}
			return hash;
		}

		bool operator()(const string& s1, const string& s2) const
		{
			return s1 < s2;
		}
};


class CG_str_hash
{
	private:
		typedef hash_map<const string, CG_flip_flop, hasher> ff_hash_map_type;
		ff_hash_map_type my_hash_map;
	public:
		CG_str_hash();
		~CG_str_hash();
		bool CG_ff_hash_insert(CG_flip_flop& ff);
		long CG_str_hash_get_size();
		CG_flip_flop& CG_str_hash_get(const char *ff_name);
		bool CG_str_hash::CG_str_hash_erase(const char *ff_name);
};
